package edu.msg.hrappy.backend.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author Torok Eniko
 */
@Entity
@Table(name = "UserGroup")
public class UserGroup extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private User user;
	private Group group;
	private String userName;
	private String groupName;

	public UserGroup() {
		// CONSTR
	}

	public UserGroup(User user, Group group) {
		this.user = user;
		this.group = group;
		this.userName = user.getUserName();
		this.groupName = group.getTypeName().name();
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@ManyToOne
	@JoinColumn(name = "user_id")
	public User getUser() {
		return user;
	}

	@ManyToOne
	@JoinColumn(name = "group_id")
	public Group getGroup() {
		return group;
	}

	@Column(name = "userName")
	public String getUserName() {
		return userName;
	}

	@Column(name = "groupName")
	public String getGroupName() {
		return groupName;
	}

}
